#pragma once

#include <stdexcept>
#include <string>
#include <functional>
#include <memory>

#include "book/book.h"


class AbcArticleManager
{
public:
    
    class ChooseBookDirError : public std::runtime_error
    {
    public:
        ChooseBookDirError() : std::runtime_error("cannot choose directory for book data") {}
        virtual ~ChooseBookDirError() {}
    };

    AbcArticleManager();

    ~AbcArticleManager();

    void setOnGenerateSucceedCallback(std::function<void(std::shared_ptr<book::Book>)> &&callback);

    void forceGenerate();

    void afterGitTagPosted();

    void afterBookDataDirActivated(const fs::path &dir);

private:
    void afterGitRepoContentChanged(const std::string &id);

    void makeArticleData(const std::string &id);

private:
    std::function<void(std::shared_ptr<book::Book>)> onGenerateSucceed_;
};
